<h1>Listing users</h1>

<div class="fbblueboxlite">
  <table>
    <div class="fbgreybox"><h2>CAMT Accounts</h2></div>
    <tr>
      <th style="width:300px;text-align:left;">User name</th>
      <th style="width:200px;text-align:left;">Role</th>
    </tr>

    <% @users.each do |user| %>
        <% if user.role == "camt" %>
            <tr>
              <td><%= user.name %></td>
              <td><%= user.role.capitalize %></td>
              <td><%= link_to 'Show', user %></td>
              <td><%= link_to 'Edit', edit_user_path(user) %></td>
              <td><%= link_to 'Delete', user, :confirm => 'Are you sure?', :method => :delete %></td>
            </tr>
        <% end %>
    <% end %>
  </table>

  <table>
    <div class="fbgreybox"><h2>Company Accounts</h2></div>
    <tr>
      <th style="width:300px;text-align:left;">User name</th>
      <th style="width:200px;text-align:left;">Role</th>
    </tr>

    <% @users.each do |user| %>
        <% if user.role == "company" %>
            <tr>
              <td><%= user.name %></td>
              <td><%= user.role.capitalize %></td>
              <td><%= link_to 'Show', user %></td>
              <td><%= link_to 'Edit', edit_user_path(user) %></td>
              <td><%= link_to 'Delete', user, :confirm => 'Are you sure?', :method => :delete %></td>
            </tr>
        <% end %>
    <% end %>
  </table>

  <table>
    <div class="fbgreybox"><h2>Student Accounts</h2></div>
    <tr>
      <th style="width:300px;text-align:left;">User name</th>
      <th style="width:200px;text-align:left;">Role</th>
    </tr>

    <% @users.each do |user| %>
        <% if user.role == "student" %>
            <tr>
              <td><%= user.name %></td>
              <td><%= user.role.capitalize %></td>
              <td><%= link_to 'Show', user %></td>
              <td><%= link_to 'Edit', edit_user_path(user) %></td>
              <td><%= link_to 'Delete', user, :confirm => 'Are you sure?', :method => :delete %></td>
            </tr>
        <% end %>
    <% end %>
  </table>

  <table>
    <div class="fbgreybox"><h2>Admin Accounts</h2></div>
    <tr>
      <th style="width:300px;text-align:left;">User name</th>
      <th style="width:200px;text-align:left;">Role</th>
    </tr>

    <% @users.each do |user| %>
        <% if user.role == "admin" %>
            <tr>
              <td><%= user.name %></td>
              <td><%= user.role.capitalize %></td>
              <td><%= link_to 'Show', user %></td>
              <td><%= link_to 'Edit', edit_user_path(user) %></td>
              <td><%= link_to 'Delete', user, :confirm => 'Are you sure?', :method => :delete %></td>
            </tr>
        <% end %>
    <% end %>
  </table>

</div>
<br />

<div class="fbgreyboxbuttom">
  <%= button_to 'New User', new_user_path %>
</div>